ensure we can delete invalid read-only items
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Fri, 21 Feb 2025 12:47:00 +0000 (13:47 +0100)
committerJyrki Gadinger <nilsding@nilsding.org>
Sat, 22 Feb 2025 11:02:43 +0000 (12:02 +0100)
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/gui/folder.cpp

index 85e0049950bb5bca8cceeb95107d64a8a48a58a0..cc5a0f74a76912deeb4e3dd87ac2fbac5bf59747 100644 (file)
@@ -1736,7 +1736,16 @@ void Folder::slotNeedToRemoveRemnantsReadOnlyFolders(const QList<SyncFileItemPtr
 
     setSyncPaused(true);
     for(const auto &oneFolder : folders) {
-        FileSystem::removeRecursively(localPath + oneFolder->_file);
+#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
+        const auto fileInfo = QFileInfo{localPath + oneFolder->_file};
+        const auto parentFolderPath = fileInfo.dir().absolutePath();
+        const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
+#endif
+        if (oneFolder->_type == ItemType::ItemTypeDirectory) {
+            FileSystem::removeRecursively(localPath + oneFolder->_file);
+        } else {
+            FileSystem::remove(localPath + oneFolder->_file);
+        }
     }
     callback(true);
     setSyncPaused(false);